package com.team2.insulatingtools.modular.system.utils;

import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
import cn.stylefeng.roses.kernel.auth.api.pojo.login.basic.SimpleRoleInfo;
import java.util.List;

/**
 * @author yangqian
 * @date 2023-04-04 14:13
 * @description
 **/
public class ToolsUtils {

    /**
     * 判断角色是否是普通车间/班组，如果是，返回组织结构id,否则返回Null
     */
    public static Long isNormalOrg(){
        LoginUser user = LoginContext.me().getLoginUser();
        List<SimpleRoleInfo> roles = user.getSimpleRoleInfoList();
        for (SimpleRoleInfo role :roles) {
            if(role.getRoleCode().indexOf("workshop/team") > -1){
                return user.getOrganizationId();
            }
        }
        return null;
    }

}
